package com.woniu.controller;

import com.woniu.entity.RbacMenu;
import com.woniu.entity.ResponseEntity;
import com.woniu.service.RbacMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Rain
 * @Description :
 * @date 2022/09/09 11:09
 */
@RestController
@RequestMapping("/rbacMenu")
@CrossOrigin
public class RbacMenuController {

    @Autowired
    RbacMenuService rbacMenuService;

    @GetMapping("/")
    public ResponseEntity findAllMenu(){
        return rbacMenuService.findAllMenu();
    }

    @PutMapping("/")
    public ResponseEntity editOne(@RequestBody RbacMenu menu){
        return rbacMenuService.editOne(menu);
    }

    @PutMapping("/{id}/{fid}")
    public ResponseEntity updateOneMenuFID(@PathVariable Integer id,
                                           @PathVariable Integer fid){
        return rbacMenuService.updateOneMenuFID(id,fid);
    }

    /**
     * 根据用户ID查找角色ID,再根据角色ID查找菜单
     */
    @GetMapping("/{id}")
    public ResponseEntity findMenuByManagerID(@PathVariable Integer id) {
        return rbacMenuService.findMenuByManagerID(id);
    }
}
